import { scrolltoelement } from "./scrolltoelement";

export function scrollIntoViewclicklistener(e: Event) {
    if (!(e instanceof MouseEvent)) {
        return;
    }
    let target = e.target;
    console.log(e);

    if (
        target &&
        target instanceof HTMLAnchorElement &&
        target.classList.contains("scrollIntoView")
    ) {
        const ele = target;
        if (!ele) {
            return;
        }
        console.log(target);
        //@ts-ignore
        requestIdleCallback(() => {
            requestAnimationFrame(() => {
                if (ele instanceof Element) {
                    scrolltoelement(ele);
                }
            });
        });
    }
}
